package com.gpb.common.method;

import java.util.HashMap;
import java.util.List;

import net.sf.json.JSONObject;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;
/**
 * JSON转Map
 * @author GuoPengBin
 * @dateTime Mar 25, 2014  4:33:18 PM
 */
public class JSON2MapMethod implements TemplateMethodModel {

	public Object exec(List arg0) throws TemplateModelException {
		if(arg0.size()>0){
			try {
				return JSONObject.fromObject(arg0.get(0).toString());
			} catch (Exception e) {
				return new HashMap<String,String>();
			}
		}
		return new HashMap<String,String>();
	}

}
